import("//llvm/utils/TableGen/tablegen.gni")

tablegen("AArch64GenCallingConv") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [ "-gen-callingconv" ]
  td_file = "AArch64.td"
}

tablegen("AArch64GenDAGISel") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [ "-gen-dag-isel" ]
  td_file = "AArch64.td"
}

tablegen("AArch64GenFastISel") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [ "-gen-fast-isel" ]
  td_file = "AArch64.td"
}

tablegen("AArch64GenO0PreLegalizeGICombiner") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [
    "-gen-global-isel-combiner",
    "-combiners=AArch64O0PreLegalizerCombinerHelper",
  ]
  td_file = "AArch64.td"
}

tablegen("AArch64GenGlobalISel") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [ "-gen-global-isel" ]
  td_file = "AArch64.td"
}

tablegen("AArch64GenMCPseudoLowering") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [ "-gen-pseudo-lowering" ]
  td_file = "AArch64.td"
}

tablegen("AArch64GenPostLegalizeGICombiner") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [
    "-gen-global-isel-combiner",
    "-combiners=AArch64PostLegalizerCombinerHelper",
  ]
  td_file = "AArch64.td"
}

tablegen("AArch64GenPreLegalizeGICombiner") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [
    "-gen-global-isel-combiner",
    "-combiners=AArch64PreLegalizerCombinerHelper",
  ]
  td_file = "AArch64.td"
}

tablegen("AArch64GenPostLegalizeGILowering") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [
    "-gen-global-isel-combiner",
    "-combiners=AArch64PostLegalizerLoweringHelper",
  ]
  td_file = "AArch64.td"
}

tablegen("AArch64GenRegisterBank") {
  visibility = [ ":LLVMAArch64CodeGen" ]
  args = [ "-gen-register-bank" ]
  td_file = "AArch64.td"
}

static_library("LLVMAArch64CodeGen") {
  deps = [
    ":AArch64GenCallingConv",
    ":AArch64GenDAGISel",
    ":AArch64GenFastISel",
    ":AArch64GenGlobalISel",
    ":AArch64GenMCPseudoLowering",
    ":AArch64GenO0PreLegalizeGICombiner",
    ":AArch64GenPostLegalizeGICombiner",
    ":AArch64GenPostLegalizeGILowering",
    ":AArch64GenPreLegalizeGICombiner",
    ":AArch64GenRegisterBank",

    # See https://reviews.llvm.org/D69130
    "AsmParser:AArch64GenAsmMatcher",
    "MCTargetDesc",
    "TargetInfo",
    "Utils",
    "//llvm/lib/Analysis",
    "//llvm/lib/CodeGen",
    "//llvm/lib/CodeGen/AsmPrinter",
    "//llvm/lib/CodeGen/GlobalISel",
    "//llvm/lib/CodeGen/SelectionDAG",
    "//llvm/lib/IR",
    "//llvm/lib/MC",
    "//llvm/lib/Support",
    "//llvm/lib/Target",
    "//llvm/lib/Transforms/CFGuard",
    "//llvm/lib/Transforms/Scalar",
    "//llvm/lib/Transforms/Utils",
  ]
  include_dirs = [ "." ]
  sources = [
    "AArch64A53Fix835769.cpp",
    "AArch64A57FPLoadBalancing.cpp",
    "AArch64AdvSIMDScalarPass.cpp",
    "AArch64AsmPrinter.cpp",
    "AArch64BranchTargets.cpp",
    "AArch64CallingConvention.cpp",
    "AArch64CleanupLocalDynamicTLSPass.cpp",
    "AArch64CollectLOH.cpp",
    "AArch64CompressJumpTables.cpp",
    "AArch64CondBrTuning.cpp",
    "AArch64ConditionOptimizer.cpp",
    "AArch64ConditionalCompares.cpp",
    "AArch64DeadRegisterDefinitionsPass.cpp",
    "AArch64ExpandImm.cpp",
    "AArch64ExpandPseudoInsts.cpp",
    "AArch64FalkorHWPFFix.cpp",
    "AArch64FastISel.cpp",
    "AArch64FrameLowering.cpp",
    "AArch64ISelDAGToDAG.cpp",
    "AArch64ISelLowering.cpp",
    "AArch64InstrInfo.cpp",
    "AArch64LoadStoreOptimizer.cpp",
    "AArch64LowerHomogeneousPrologEpilog.cpp",
    "AArch64MCInstLower.cpp",
    "AArch64MachineFunctionInfo.cpp",
    "AArch64MacroFusion.cpp",
    "AArch64PBQPRegAlloc.cpp",
    "AArch64PromoteConstant.cpp",
    "AArch64RedundantCopyElimination.cpp",
    "AArch64RegisterInfo.cpp",
    "AArch64SIMDInstrOpt.cpp",
    "AArch64SLSHardening.cpp",
    "AArch64SelectionDAGInfo.cpp",
    "AArch64SpeculationHardening.cpp",
    "AArch64StackTagging.cpp",
    "AArch64StackTaggingPreRA.cpp",
    "AArch64StorePairSuppress.cpp",
    "AArch64Subtarget.cpp",
    "AArch64TargetMachine.cpp",
    "AArch64TargetObjectFile.cpp",
    "AArch64TargetTransformInfo.cpp",
    "GISel/AArch64CallLowering.cpp",
    "GISel/AArch64GlobalISelUtils.cpp",
    "GISel/AArch64InstructionSelector.cpp",
    "GISel/AArch64LegalizerInfo.cpp",
    "GISel/AArch64O0PreLegalizerCombiner.cpp",
    "GISel/AArch64PostLegalizerCombiner.cpp",
    "GISel/AArch64PostLegalizerLowering.cpp",
    "GISel/AArch64PostSelectOptimize.cpp",
    "GISel/AArch64PreLegalizerCombiner.cpp",
    "GISel/AArch64RegisterBankInfo.cpp",
    "SVEIntrinsicOpts.cpp",
  ]
}

# This is a bit different from most build files: Due to this group
# having the directory's name, "//llvm/lib/Target/AArch64" will refer to this
# target, which pulls in the code in this directory *and all subdirectories*.
# For most other directories, "//llvm/lib/Foo" only pulls in the code directly
# in "llvm/lib/Foo". The forwarding targets in //llvm/lib/Target expect this
# different behavior.
group("AArch64") {
  deps = [
    ":LLVMAArch64CodeGen",
    "AsmParser",
    "Disassembler",
    "MCTargetDesc",
    "TargetInfo",
    "Utils",
  ]
}
